///////////////////////////////////////////////////
/// tototoy Code
/// $Id: singleton.h 28 2009-09-27 10:03:30Z tonyjobmails $
/// $Date: 2009-09-27 10:03:30 +0000 (Sun, 27 Sep 2009) $
/// $Author: tonyjobmails $
/// $Revision: 28 $
/// E-mail: tonyjobmails@gmail.com
/// filename: base.h
/// function: 单件模式基类
///////////////////////////////////////////////////

#ifndef _SINGLETON_H
#define _SINGLETON_H

template<typename _T>
class singleton
{
	protected:
		singleton() {}
		~singleton() {}
		
	public:
		static _T *instance;
		static _T* get_instance()
		{
			if(instance == NULL)
			{
				instance = new _T;
			}
			return instance;
		}
		static void del_instance()
		{
			if(instance)
				delete instance;
			instance = NULL;
		}
};

template<typename _T>
singleton::instance = NULL;

#endif
